#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<bool> x(26, 1);
int t = 26, r = 0;
for (int i = 0; i < n; i++) {
string s;
char a;
cin >> a;
if (a == '.') {
cin >> s;
for (char c : s)
if (x[c-'a'])
x[c-'a'] = 0, t--;
} else if (a == '!') {
cin >> s;
if (t == 1) {
r++;
continue;
}
vector<bool> y(26);
for (char c : s) y[c-'a'] = 1;
for (int i = 0; i < 26; i++)
if (!y[i] && x[i])
x[i] = 0, t--;
} else {
cin >> a;
if (t == 1 && !x[a-'a']) r++;
else if (x[a-'a']) x[a-'a'] = 0, t--;
}
}
cout << r << '\n';
}
1530A - Binary Decimal | 1472D - Even-Odd Game |
441C - Valera and Tubes | 1328E - Tree Queries |
265A - Colorful Stones (Simplified Edition) | 296A - Yaroslav and Permutations |
967B - Watering System | 152A - Marks |
1398A - Bad Triangle | 137A - Postcards and photos |
1674D - A-B-C Sort | 334A - Candy Bags |
855A - Tom Riddle's Diary | 1417A - Copy-paste |
1038A - Equality | 1061A - Coins |
1676E - Eating Queries | 1447A - Add Candies |
1721D - Maximum AND | 363C - Fixing Typos |
1401A - Distance and Axis | 658A - Bear and Reverse Radewoosh |
1721E - Prefix Function Queries | 977E - Cyclic Components |
1140D - Minimum Triangulation | 75C - Modified GCD |
1722A - Spell Check | 1722B - Colourblindness |
1722D - Line | 1722C - Word Game |